﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using ExtBusiness;
using ExtBusiness.Interface;
using WebControls;

public partial class office_Buzheng : System.Web.UI.Page
{
    private ClsSubmitInfo submit = new ClsSubmitInfo();
    private string strFlowid = string.Empty;
    private string strFlowName = string.Empty;
    private string strIId = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["action"] == "buzheng")
        {
            string iid = Request.Params["iid"];
            ClsSubmitInfo.UpdateFlag(iid, -1);            

            //发送消息 update by zhongjian 20091230
            submit.SetMsg(iid, "驳回办理");
        }

        if (Request["flowid"] != null)
        {
            strFlowid = Request["flowid"].ToString ();
        }

        gridviewCar.DataKeyNames = new string[] { "IID" };

        if (!IsPostBack)
        {
            GridviewDatabind();
        }
    }

    #region 数据绑定
    private void GridviewDatabind()
    {
        strFlowName = submit.GetWnameWithWid(strFlowid);
        DataTable dt = submit.GetAlreadySubmit(strFlowName);
        gridviewCar.DataSource = dt;
        gridviewCar.RecordCount = dt.Rows.Count;
        gridviewCar.DataBind();
    }
    #endregion 

    /// <summary>
    /// datagrid数据加载
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void recvgrid_OnLoadData(object sender, EventArgs e)
    {
        this.GridviewDatabind();
    }

    /// <summary>
    /// 完成事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gridviewCar_OnComplelteClick(object sender, CustomGridViewEventArgs e)
    {
        if (e == null)
        {
            return;
        }

        if (e.SingleOrMultiSelectKey.Value.ToString () == "")
        {
            return;
        }

        strIId = e.SingleOrMultiSelectKey.Value.ToString();

        ClientScript.RegisterStartupScript(this.GetType(), "scr", string.Format(@"<script>window.opener.document.getElementById(""hidIId"").value={0};window.close();</script>", strIId));
    }


    #region 行创建
    protected void gridviewCar_RowCreated(object sender, GridViewRowEventArgs e)
    {
        switch (e.Row.RowType)
        {
            case DataControlRowType.DataRow:

                DataRowView drv = e.Row.DataItem as DataRowView;
                if (drv == null)
                {
                    break;
                }

                HyperLink hybz = e.Row.FindControl("hybz") as HyperLink;
                if (hybz != null)
                {
                    hybz.Attributes.Add("OnClick", "return confirm('确定要补正补齐该办理事项?')");
                    hybz.NavigateUrl = "Buzheng.aspx?action=buzheng&iid=" + drv["iid"] + "&flowid=" + strFlowid + "&requester=" + drv["requester"];
                }
                break;
        }
    }
    #endregion


    protected string GetIId()
    {
        return strIId;
    }

}
